<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String id = request.getParameter("id");
%>
<html>
	<head>
	
		<script src="<%=path%>/static/js/jquery-1.6.1.min.js" type="text/javascript"></script>
		<script src="<spring:url value="/static/js/jquery.easyui.min.js" />" type="text/javascript" ></script>
		<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/themes/default/easyui.css">
		<link href="<%=path%>/static/css/themes/icon.css" rel="stylesheet" type="text/css" />
	</head>

<body>
	<table style="margin: 5;">
	<tr>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<a href="#" id="btn-back" onclick="$('#provinceWindow').window('close');"
		class="easyui-linkbutton" iconCls="icon-back">返回</a> 
	<a href="#" id="ButonGetCheck" onclick="getCheckAndSubmit(<%=id%>);" class="easyui-linkbutton"
			iconCls="icon-save">保存</a>
	</td>
	</tr>
	</table>

    <table id="dg" title="" class="easyui-datagrid" 
            data-options="selectOnCheck:false,rownumbers:true,singleSelect:false,url:'<%=path%>/spcodeprovince/list?spcodeId=<%=id%>',method:'POST',
            onLoadSuccess:function(data){
        	if(data){
            	$.each(data.rows, function(index, item){
	                if(item.status=='1'){
	                    $('#dg').datagrid('checkRow', index);
	                }
            	});
        	}
    		},
onClickCell: function (rowIndex, field, value) {

	var endEditing = function () {
	    if (editIndex == undefined) { return true }
	    if ($('#dg').datagrid('validateRow', editIndex)) {
	        var ed = $('#dg').datagrid('getEditor', { index: editIndex, field: 'dayMax' });
	        var number = $(ed.target).numberbox('getValue');

	        $('#dg').datagrid('getRows')[editIndex]['dayMax'] = number;
	        $('#dg').datagrid('endEdit', editIndex);
	        //$('#dg').datagrid('selectRow', editIndex);
	        editIndex = undefined;
	        return true;
	    } else {
	        return false;
	    }
	}

	var editIndex = undefined;
	    if (field != 'dayMax')
	        return;
	      
	    if (rowIndex != editIndex) {
	        if (endEditing()) {
	            $('#dg').datagrid('beginEdit', rowIndex);
	            editIndex = rowIndex;
	            var ed = $('#dg').datagrid('getEditor', { index: rowIndex, field: 'dayMax' });
	            $(ed.target).focus().bind('blur', function () {
	                endEditing();
	            });
	        } else {
	            //$('#dg').datagrid('selectRow', editIndex);
	            editIndex = undefined;
	        }
	    }

}
    ">
        <thead>
            <tr>
                <th data-options="field:'null',checkbox:true"></th>
                <th data-options="field:'provinceCode',width:20,
             	           formatter: function(value,row,index){
                          	var showMsg;
                          	$.each(provinceJSON,function(index,item){
                          		if(item.code == value){
                          			showMsg = item.name;
                          			return;
                          		} 
                          	});
                          	return showMsg;
                          }
                ">省份</th>
                <th data-options="field:'dayMax',width:20,editor:{type:'numberbox',options:{min:0},required:true} ">日上限</th>
            </tr>
        </thead>
    </table>
</body>
</html>